@extends('admin.master')

@section('top')
<div class="top-breadcrumb pull-left">{!! Breadcrumbs::render('group-edit') !!}</div>
@endsection

@section('content')
	{!! Form::model($data, ['route' => ['admin.group.update', $data->id], 'method'=>'patch', 'class'=>'form-horizontal']) !!}
		<table class="table table-form">
			<tbody>
				<tr>
					<th width="80"><label class="control-label"><span class="text-danger require-star">*</span> 名称</label></th>
					<td>{!! Form::text('name', null, ['class'=>'form-control len']) !!}</td>
				</tr>
				<tr>
					<th><label class="control-label">级别</label></th>
					<td>{!! Form::text('level', null, ['class'=>'form-control len100']) !!}</td>
				</tr>
				<tr>
					<th><label class="control-label">栏目</label></th>
					<td>
						<div class="panel panel-default">
							<div class="panel-heading">栏目选择</div>
							<div class="panel-body">
								<ul class="group-auth clearfix">
									@if (!empty($tree))
										@foreach($tree as $key=>$value)
										<li>
											<h3>
												<div class="checkbox">
													<label>
														{!! Form::checkbox("menu[]", $value['id'], null) !!}
														<span>{{ $value['name'] }}</span>
													</label>
												</div>
											</h3>
											<ul class="menu-children">
											@if (!empty($value['children']))
												@foreach($value['children'] as $children)
												<li>
													<div class="checkbox">
														<label>
															{!! Form::checkbox("menu[]", $children['id'], null) !!}
															<span>{{ $children['name'] }}</span>
														</label>
													</div>
												</li>
												@endforeach
											@endif
											</ul>
										</li>
										@endforeach
									@endif
								</ul>
						  	</div>
						</div>
					</td>
				</tr>
				<tr>
					<th><label class="control-label">权限</label></th>
					<td>
						<ul class="permissions-list">
						@foreach($permissions as $value)
						@if (empty($value['auth']))
							@continue;
						@endif
						<li>
							<div class="panel panel-default">
								<div class="panel-heading">{{ $value['name'] }}</div>
						  		<div class="panel-body">
									<ul class="permissions-item clearfix">
										@foreach($value['auth'] as $label=>$auth)
										<li>
											<div class="checkbox">
												<label>
													{!! Form::checkbox("permissions[]", $label, null) !!} <span>{{ $auth['name'] }}</span>
												</label>	
											</div>
										</li>	
										@endforeach
									</ul>
						  		</div>
							</div>
						</li>
						@endforeach
						</ul>
					</td>
				</tr>
				<tr>
					<th width="80"><label class="control-label">备注</label></th>
					<td>{!! Form::textarea('remark', null, ['class'=>'form-control len', 'rows'=>3]) !!}</td>
				</tr>
				<tr>
					<td></td>
					<td>{!! Form::submit('提交', ['class'=>'btn btn-primary']) !!}</td>
				</tr>
			</tbody>
		</table>
	{!! Form::close() !!}
@endsection